<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">
        <h2>这是app1</h2>
        <cpn></cpn>
    </div>


    <div id="app2">
        <h2>这是app2</h2>
        <cpn></cpn>
    </div>


    <script>
        //创建组件构造器
        const cpnC = Vue.extend({
            template: `
            <div>
            <h2>我是标题</h2>
            <p>我是内容,,,,</p>
        </div>
            `
        })

        //注册组件(全局组件，意味着可以在多个vue实例对象中使用)
        // Vue.component('cpn', cpnC);


        const vm = new Vue({
            el: '#app',
            data: {
                message: '我是你爹!'
            },
            methods: {},
            components: { //局部组件
                //cpn:使用组件时的标签名
                cpn: cpnC
            }
        });

        //创建另一个vue实例
        const app2 = new Vue({
            el: '#app2',
            data: {
                message: '我是你爹!2'
            },
            methods: {}
        });
    </script>
</body>

</html>